package com.guaoran.interview.unit.test;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;

/**
 * @Author gucheng
 * @Description
 *  单元测试2
 * 2019-04-02 13:49
 */
@RunWith(Parameterized.class)
public class UnitTestDemo2 {
    TestService service;
    int param0;
    int param1;
    int result;

    public UnitTestDemo2(int param0, int param1, int result) {
        this.param0 = param0;
        this.param1 = param1;
        this.result = result;
    }

    @Parameterized.Parameters
    public static Collection<Object[]> initParam(){
        List<Object[]> objects = Arrays.asList(new Object[][]{{1, 1, 2}, {1, 2, 3}, {1, 3, 4}, {1, 3, 5}});
        return objects;
    }
    @Before
    public void before(){
        System.out.println("service 已实例化");
        service = new TestService();
    }
    @Test
    public void testAdd() {
        Assert.assertEquals(result,service.add(param0, param1));
    }
}
